#!/bin/sh
#
# rocketmq - this script starts and stops the rocketmq daemon
#
# chkconfig: - 85 15

export JAVA_HOME={{jdk_base_path}}
export PATH=$JAVA_HOME/bin:$PATH
 
ROCKETMQ_HOME={{ rocketmq_base }}
ROCKETMQ_BIN=${ROCKETMQ_HOME}/bin
LOG_DIR=${ROCKETMQ_HOME}/logs
NAMESERVER_LOG=${LOG_DIR}/namesrv.log
 
start() {
    if [ ! -d ${LOG_DIR} ];then
        mkdir ${LOG_DIR}
    fi
    cd ${ROCKETMQ_HOME}
    nohup sh bin/mqnamesrv > ${NAMESERVER_LOG} 2>&1 &
    echo -n "The Name Server boot success..."
}
stop() {
    cd ${ROCKETMQ_HOME}
    sh bin/mqshutdown namesrv
}
restart() {
    stop
    sleep 5
    start
}
 
 
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 2
	;;
esac
